Page({
  data: {
    bgIMG:[
      {
        url:"https://img.alicdn.com/imgextra/i4/4161056916/O1CN01x8QJd620xZoqta7y4_!!4161056916.jpg",
        width:750,
        height:846,
      },
      {
        url:"https://img.alicdn.com/imgextra/i2/4161056916/O1CN014AP0jH20xZolR0Jbj_!!4161056916.jpg",
        width:750,
        height:614
      },
      // {
      //   url:"https://img.alicdn.com/imgextra/i3/4161056916/O1CN01rdM6K820xZorZDqcZ_!!4161056916.jpg",
      //   width:750,
      //   height:796
      // },
      // {
      //   url:"https://img.alicdn.com/imgextra/i3/4161056916/O1CN01rdM6K820xZorZDqcZ_!!4161056916.jpg",
      //   width:750,
      //   height:477
      // }
    ],
    goods:[
      {
        url:"https://img.alicdn.com/imgextra/i2/4161056916/O1CN01tBvLIi20xZomXLm9K_!!4161056916.png",
        width:309,
        height:438,
        id:550080595188
      },
      {
        url:"https://img.alicdn.com/imgextra/i4/4161056916/O1CN01jXI07u20xZortRzXQ_!!4161056916.png",
        width:309,
        height:438,
        id:594340962464
      },
      {
        url:"https://img.alicdn.com/imgextra/i3/4161056916/O1CN0151PbZ920xZomzTWnd_!!4161056916.png",
        width:309,
        height:438,
        id:579220742563
      },
      {
        url:"https://img.alicdn.com/imgextra/i1/4161056916/O1CN01CkBah020xZovhxL5C_!!4161056916.png",
        width:309,
        height:438,
        id:595368410021
      }
    ],
    likeBtn:{
      url:"https://img.alicdn.com/imgextra/i3/4161056916/O1CN01FbjX1g20xZoqteYfA_!!4161056916.png",
      width:130,
      height:42
    },
    likeBtnH:{
      url:"https://img.alicdn.com/imgextra/i4/4161056916/O1CN01IYiT6q20xZopdcyqj_!!4161056916.png",
      width:130,
      height:42
    },
    addCartBtn:{
      url:"https://img.alicdn.com/imgextra/i1/4161056916/O1CN01n92oPE20xZqLTRIgX_!!4161056916.png",
      width:130,
      height:42
    },

    likeBtnPosi:"160,36",
    addCartBtnPosi:"18,34"
    
  
  },

  //获取收藏商品信息
  getCollectGoods(){
    getApp().cloud.application.httpRequest({
      'path' : '/api/c/task/getCollectProduct', 
      'method':'GET',
      'headers':{ "Content-Type":"application/json"},
      'params':{},
      'body':{},
      'exts':{}  }).then(res => {

      console.log("收藏商品信息",res);

      //判断是否是正常状态
      if(res.code != 200){

        // my.alert({
        //   content:res.msg
        // }) 
        
      }else{
        // my.alert({
        //   content:"收藏"
        // })
      }
    })
  },

  //收藏接口
  collectGoods(goodsId){
    getApp().cloud.application.httpRequest({
      'path' : '/api/c/task/collect', 
      'method':'POST',
      'headers':{ "Content-Type":"application/json"},
      'params':{},
      'body':{ productId : goodsId },
      'exts':{}  }).then(res => {

      console.log("收藏接口",res);
      console.log("收藏id",goodsId);

      //判断是否是正常状态
      if(res.code != 200){

        my.alert({
          content:res.msg
        }) 
        
      }else{
        my.alert({
          content:"收藏成功"
        })
      }
    })
  },

  //浏览接口
  lookGoods(){
    getApp().cloud.application.httpRequest({
      'path' : '/api/c/task/viewProduct', 
      'method':'POST',
      'headers':{ "Content-Type":"application/json"},
      'params':{},
      'body':{},
      'exts':{}  }).then(res => {

      console.log("浏览商品",res);

      //判断是否是正常状态
      if(res.code != 200){

        my.alert({
          content:res.msg
        }) 
        
      }else{
        my.alert({
          content:"浏览成功"
        })
      }
    })
  },

  onLoad() {

    this.getCollectGoods();

  },
});

